import api from "../../api/mop";
import { err, toast } from "../../utils/wxapi";
Page({
  /**
   * 页面的初始数据
   */
  data: { list: [] },

  onShow() {
    this.getlist();
  },
  async getlist() {
    try {
      const res = await api.work_type();
      if (res.respCode === 200) {
        const list = JSON.parse(res.source);
        console.log(list);
        this.setData({ list });
      }
    } catch (error) {
      err(error);
    }
  },
  del(e) {
    const { id } = e.currentTarget.dataset;
    wx.showModal({
      title: "提示",
      content: "您确定删除该福利标签吗？",
      complete: async (res) => {
        if (res.confirm) {
          const { respCode, msg } = await api.delwork_type({ id });
          if (respCode === 200) {
            toast("删除成功");
            this.getlist();
          } else {
            toast(msg);
          }
        }
      },
    });
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
});
